<?php

declare (strict_types=1);


namespace app\api\controller;

use app\common\model\Account as AccountModel;
use app\common\model\Assets;
use app\common\tool\Result;

class Account extends Base
{
    public function index()
    {

        $list = Assets::getFields(3);
        $result = [];
        foreach ($list as $key => $v) {
            $result[] = [
                'title' => $v,
                'account' => $key,
                'balance' => $this->user->assets->$key
            ];
        }
        return Result::success('success', $result);
    }

    public function getList()
    {
        $map = ['type' => $this->request->get()['type'], 'uid' => $this->user->id,'is_grant' => 2];
        return Result::fastReturn(AccountModel::getPageList($map, '*', $this->getPage(), 20, false, ['take']));

    }
}